<?php if (isset($categories)): ?>
    <div class="posts form">
        <?php echo $this->Form->create('Post', array('class' => 'form-horizontal', 'inputDefaults' => array('label' => false))); ?>
        <fieldset>
            <h2><span class="glyphicon glyphicon-edit"></span><?php echo __('Chỉnh Sửa Bài'); ?></h2>
            <hr />
            <div class="form-group">
                <label class="col-md-2 control-label" for="category">Mục <span class="text-danger">*</span></label>
                <div class="col-md-4">
                    <?php echo $this->Form->input('id_category', array('options' => $categories, 'class' => 'form-control')); ?>
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-2 control-label" for="title">Tiêu Đề <span class="text-danger">*</span></label>
                <div class="col-md-6">
                    <?php echo $this->Form->input('title', array('type' => 'text', 'class' => 'form-control', 'placeholder' => 'Tiêu đề...')); ?>
                </div>
            </div>

            <div class="form-group">
                <label class="col-md-2 control-label" for="content">Nội Dung <span class="text-danger">*</span></label>
                <div class="col-md-6">
                    <?php echo $this->Form->input('content', array('class' => 'form-control', 'type' => 'textarea', 'placeholder' => 'Nội dung...', 'rows' => 15)); ?>
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">Ảnh Minh Họa <span class="text-danger">*</span></label>
                <div class="col-md-4">
                    <?php echo $this->Form->input('img',array('class'=>'image-demo','type'=>'text')) ?>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-2 col-md-offset-2">
                    <?php echo $this->Form->Submit(__('Post'), array('class' => 'btn btn-sm btn-info form-control btnPost')); ?>
                </div>
            </div>
        </fieldset>
        <?php echo $this->Form->end(); ?>
    </div>
    <?php
    echo $this->Html->script('jquery-1.11.1.min.js', array('inline' => true));
    echo $this->Html->script('tinymce/tinymce.min.js', array('inline' => true));
    ?>
    <?php $this->TinymceElfinder->defineElfinderBrowser() ?>
    <script type="text/javascript">
        $(".btnPost").click(function() {
            tinyMCE.triggerSave(false, true);
        });
        tinymce.init({
            selector: "textarea",
            theme: "modern",
            plugins: [
                "advlist autolink lists link image charmap print preview hr anchor pagebreak",
                "searchreplace wordcount visualblocks visualchars code fullscreen",
                "insertdatetime media nonbreaking save table contextmenu directionality",
                "emoticons template paste textcolor colorpicker textpattern"
            ],
            toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
            toolbar2: "preview media | forecolor backcolor emoticons",
            image_advtab: true,
            file_browser_callback: elFinderBrowser,
            width: '700',
            height: '380',
            relative_urls: false
        });
        tinymce.init({
            selector: ".image-demo",
            plugins: "image",
            toolbar1: "image",
            width: '700',
            height: '380',
            image_advtab: false,
            file_browser_callback: elFinderBrowser,
        });
    </script>
<?php endif; ?>